package edu.sctu.wulixia.month6.day20150614;

import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

/**
 * Created by user05 on 2015/6/14.
 */
public class PrintChar {
    public void createFile() {
        File file = new File("D://nnn");
        if (!file.exists()) {
            System.out.println("文件夹nnn不存在");
            file.mkdir();
            System.out.println("文件夹nnn创建成功");
        }
    }

    public void createDoument() throws IOException {
        File file = new File("D://nnn//wlx.txt");

        try {
            file.createNewFile();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }

    public void getFileInfo() throws IOException {
        int countbyte;
        int count = 0;
        FileReader fileReader = new FileReader(new File("D://nnn//wlx.txt"));
        FileWriter fileWriter = new FileWriter(new File("D://nnn//wwlx.txt"));
        char[] buffer = new char[1024];

        while ((countbyte = fileReader.read(buffer)) != -1) {
            //将字节转换为字符串输出。

            count += countbyte;
            fileWriter.write(buffer, 0, count);
            String string = new String(buffer);
            System.out.println(string);
            for (char c:buffer) {
                System.out.println(c);
            }
        }
        fileWriter.close();
        fileReader.close();

    }
}
